package com.gyms.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

import utils.StringUtils;

/**
 * Created by ltx on 17/6/6
 * 公用的含有TabLayout的ViewPager适配器
 */

public class ComTabViewPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> mFragments;
    private List<String> mTabStrs;

    public ComTabViewPagerAdapter(FragmentManager fm,List<Fragment> mFragments,List<String> mTabStrs) {
        super(fm);
        this.mFragments=mFragments;
        this.mTabStrs=mTabStrs;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return StringUtils.isNull(mFragments)?0:mFragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTabStrs.get(position);
    }
}
